package main

import "fmt"

// 结构体的继承

type Animal struct {
	Name string
}

func (a *Animal) AnimalSpeak() {
	fmt.Println("I am a animal ", a.Name)
}

type Dog struct {
	Age int
	*Animal
}

func (d *Dog) DogSpeak() {
	fmt.Println("I am a dog ", d.Name, d.Age)
}

func main() {
	fmt.Println("-----------------------------------------------")
	var d = Dog{Age: 22, Animal: &Animal{Name: "Dog"}}
	d.Name = "小黄"
	d.AnimalSpeak()
	d.DogSpeak()

}
